package com.xiyuan.smartutils;

import com.xiyuan.smartutils.reflect.Unsafe;

/**
 * 关闭工具方法
 *
 * @version v1.0.0 @author lgz 2021年3月17日 新建与整理
 */
@SuppressWarnings("SpellCheckingInspection")
public final class Closes {
    static {
        Unsafe.init();
    }
    
    /**
     * 关闭并忽略异常
     */
    public static void closeIgnoreException(AutoCloseable closeable) {
        if (closeable == null) {return;}
        try {closeable.close();}
        catch (Throwable e) {}
    }
    
    /**
     * 关闭多个忽略异常
     */
    public static void closeIgnoreException(AutoCloseable... closeables) {
        for (AutoCloseable closeable : closeables) {closeIgnoreException(closeable);}
    }
}

